package lib.pacificapp.app;

import lib.pacificapp.util.ICookie;
import lib.pacificapp.util.Networker;
 
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle; 
import android.view.KeyEvent;
import android.view.WindowManager;

public class Action extends Activity {
    /***获取APP缓存信息*/
	protected ICookie cookie(String cookieName){
		 return new ICookie(this,cookieName);
	     } 
	protected ICookie cookie(int cookieName){
		  return new ICookie(this,String.valueOf(cookieName));
	     }
	/**是放入容器内*/
	protected boolean isPushOnContainer(){
		return true;
	}
    protected void onCreate(Bundle savedInstanceState) {
		 super.onCreate(savedInstanceState);
		 if(isPushOnContainer())
		 ActionContainer.getInstance().push(this);
  		 getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
          /***测量尺寸
		    WindowManager wm = this.getWindowManager();
            **/
	     }
//    private  int getStatusHeight() {
//
//		int statusHeight = -1;
//		try {
//			Class clazz = Class.forName("com.android.internal.R$dimen");
//			Object object = clazz.newInstance();
//			int height = Integer.parseInt(clazz.getField("status_bar_height")
//					.get(object).toString());
//			statusHeight =getResources().getDimensionPixelSize(height);
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//		return statusHeight;
//	}
    
 
  
     
 
     protected void start(Class<? extends Activity> activity) {
    	   Intent intent = new Intent(Action.this,(Class<?>) activity);
		         startActivity(intent);
     } 
  	  
    protected boolean isNetwork(){
    	  int netStatus=Networker.load(this).status;
 		  if(!Networker.isMessage3g
				 &&netStatus==Networker.TYPE_3G ){
			     //_tool().message("您现在处于3G网络,请注意流量");
			     Networker.isMessage3g=true;
		     }
    	     return netStatus!=Networker.TYPE_NULL;
     } 
     public static final int KEY_BACK=-1;
	    public void input(int keycode){
	    	   if(keycode==KEY_BACK){
	    		    finish();
	    	   } 
	    }
	     @Override  
	    public boolean onKeyDown(int keyCode, KeyEvent event)  
	    {       
	    	    input(keyCode==KeyEvent.KEYCODE_BACK?KEY_BACK:keyCode);
		        return false;
	    }  
	 
		    
           
		   
		 
}
